//
//  WYCSelectionCell.m
//  信用卡管理
//
//  Created by 中企互联 on 2017/11/15.
//  Copyright © 2017年 李胜军. All rights reserved.
//

#import "WYCSelectionCell.h"
#import "WYCSelectionModel.h"

@implementation WYCSelectionCell

+ (instancetype)cellWithTableView:(UITableView *)tableView{
    WYCSelectionCell * cell = [tableView dequeueReusableCellWithIdentifier:[WYCSelectionCell ID]];
    //    cell.backgroundColor = [UIColor redColor];
    cell = [[WYCSelectionCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:[WYCSelectionCell ID]];
    
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setMember];
        
    }
    return self;
}
- (void)setMember{
    self.SelectedButton = [[UIButton alloc] init];
    self.SelectedButton.frame = CGRectMake( 40 * px, 40 * px, 60 * px, 60 * px);
    [self.SelectedButton setImage:[UIImage imageNamed:@"nomor"] forState:UIControlStateNormal];
    [self.SelectedButton setImage:[UIImage imageNamed:@"Select"] forState:UIControlStateSelected];
//    [self.SelectedButton addTarget:self action:@selector(SelectedButtonClick) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:self.SelectedButton];
    
    
    
    self.planlabel = [[UILabel alloc] init];
    self.planlabel.frame = CGRectMake(CGRectGetMaxX(self.SelectedButton.frame) + 40 * px, self.SelectedButton.y, 300 * px, self.SelectedButton.height);
    self.planlabel.font = [UIFont systemFontOfSize:SmallFont];
    [self.contentView addSubview:self.planlabel];
    
    
    self.maxNumberLabel = [[UILabel alloc] init];
    self.maxNumberLabel.frame = CGRectMake(CGRectGetMaxX(self.planlabel.frame) + 40 * px, self.planlabel.y, 250 * px, self.SelectedButton.height);
    self.maxNumberLabel.font = [UIFont systemFontOfSize:SmallFont];
    [self.contentView addSubview:self.maxNumberLabel];
    
    self.maxAmountLabel = [[UILabel alloc] init];
    self.maxAmountLabel.frame = CGRectMake(CGRectGetMaxX(self.maxNumberLabel.frame) + 40 * px, self.planlabel.y, self.contentView.width, self.SelectedButton.height);
    self.maxAmountLabel.font = [UIFont systemFontOfSize:SmallFont];
    [self.contentView addSubview:self.maxAmountLabel];
    
}
- (void)setSelectionModel:(WYCSelectionModel *)selectionModel{
    
    _selectionModel = selectionModel;
    self.SelectedButton.selected = selectionModel.isSelect;
    
    self.planlabel.text = selectionModel.planName;
    
    self.maxNumberLabel.text = [NSString stringWithFormat:@"日消费%@笔",selectionModel.maxNumber];
    
    self.maxAmountLabel.text = [NSString stringWithFormat:@"消费金额%@-%@",selectionModel.minAmount,selectionModel.maxAmount];
    
}
//- (void)SelectedButtonClick{
//    self.SelectedButton.selected = YES;
//    
//}
+(NSString *)ID{
    return @"cell";
}
@end
